<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Raca extends CI_Controller {

    public function __construct() {
        parent::__construct();
    }

    public function index() {
        $data['title_for_layout'] = 'Administra&ccedil;&atilde;o';
        $this->load->view('admin/elementos/html_header', $data);
        $this->load->view('admin/raca');
        $this->load->view('admin/elementos/html_footer');
    }

    public function adicionar() {

        $config = array(
            array(
                'field' => 'raca',
                'label' => 'Raca',
                'rules' => 'required|min_length[4]|htmlspecialchars|xss_clean'
            )
        );
        $this->form_validation->set_rules($config);
        if ($this->form_validation->run() == FALSE) {
            $this->index();
        } else {
            $data['raca'] = $this->input->post('raca');
            $this->load->model('admin/raca_model');

            if ($this->raca_model->cadastrar($data)) {
                $this->index();
            }
            else {
              echo 'Erro ao inserir a raca';
            }
        }
    }

}

/* End of file raca.php */
/* Location: ./application/controller/admin/raca.php */